package com.wx.sdk;
import com.github.wxpay.sdk.IWXPayDomain;
import com.github.wxpay.sdk.WXPayConfig;
import com.github.wxpay.sdk.WXPayConstants;

import java.io.*;

public class MyConfig extends WXPayConfig {

    private byte[] certData;

    public MyConfig() throws Exception {

    }


    public String getAppID() {
        return "wx4471669c8661258b";
    }

    public String getMchID() {
        return "1628502281";
    }

    public String getKey() {
        return "kdcnb666kdcnb666kdcnb666kdcnb666";
    }

    @Override
    public String getNotifyUrl() {
        return "https://zhengzhouchuanxiao.yourtools.icu/payment-notify/wxpay_mp-weixin";
    }

    @Override
    public boolean useSandbox() {
        return false;
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    public IWXPayDomain getWXPayDomain() {
        // 这个方法需要这样实现, 否则无法正常初始化WXPay
        IWXPayDomain iwxPayDomain = new IWXPayDomain() {

            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }

            public DomainInfo getDomain(WXPayConfig config) {
                return new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API, true);
            }
        };
        return iwxPayDomain;
    }

}